home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / system / admin-v1.2 / admin-v1 / admin next >
Encoding:
Text File  |  1995-05-20  |  27.0 KB  |  1,003 lines

  1. #!/bin/sh
  2. #
  3. # Copyright (c)1995 by Emmett Sauer & Linux Business Systems
  4. # This is NOT Shareware.. This is Freeware.. This can be included with
  5. # any package as long as these copyright notices stay intact with the software.
  6. #
  7. # Linux Business Systems - retains all rights to this script file and are by no
  8. # means liable for any damages that may be incurred when using.  It is the 
  9. # users responsibilty to know the consequences of the actions of commands given
  10. # or programs called when using this software.
  11. # Linux Business Systems is not responsible for any other software that may used
  12. # in conjunction with the Admin Menu.  We make no claims as to the validity of
  13. # any other software used other than it works on our machines.  
  14. #
  15. # It is requested that if you make any changes that you forward the changes to 
  16. # us to be considered for another release.
  17. #
  18. # emmetts@squeaky.free.org
  19. #
  20. log_name=`whoami`
  21. log_group=`groups`
  22. TVERSION="Linux Business Systems V1.2                    `date`"
  23. TITLE="`hostname`.`dnsdomainname` Admin Menu"
  24. EGROUP=/etc/group
  25. EPWORD=/etc/passwd
  26. UMAIL=/var/spool/mail
  27. PWBACK=/var/adm/passwd.bu.$UID
  28. GRPBACK=/var/adm/group.bu.$UID
  29.  
  30. # This is for your preferred editor
  31. AEDIT=/usr/local/bin/tde
  32. EDITOR=$AEDIT
  33. #
  34.  
  35. main()
  36. {
  37. while [ 0 ]; do
  38.  
  39.     dialog --title " $TITLE " \
  40.     --backtitle " $TVERSION" \
  41.     --menu "MAIN" 15 50 8 \
  42.     "1" "Security " \
  43.     "2" "System Accounting " \
  44.     "3" "Network " \
  45.     "4" "News & Mail " \
  46.     "5" "Printer " \
  47.     "6" "System Maintainance" \
  48.     "7" "Utilities" \
  49.     "8" "QUIT" 2> /tmp/mch.tmp.$$
  50.     if [ $? = 1 -o $? = 255 ]; then
  51.         /bin/rm -f /tmp/tmpmsg /tmp/mch.tmp.$$
  52.         exit
  53.     fi
  54.     choice=`cat /tmp/mch.tmp.$$`
  55.     /bin/rm -f /tmp/mch.tmp.$$
  56.     if [ "$choice" = "1" ]; then
  57.     secmain
  58.     fi
  59.     if [ "$choice" = "2" ]; then
  60.         acctmain
  61.         fi
  62.     if [ "$choice" = "3" ]; then
  63.     nmenu
  64.     fi
  65.     if [ "$choice" = "4" ]; then
  66.     nmmenu
  67.     fi
  68.     if [ "$choice" = "5" ]; then
  69.     prnt-mgmt
  70.     fi
  71.     if [ "$choice" = "6" ]; then
  72.         smain
  73.         fi
  74.     if [ "$choice" = "7" ]; then
  75.         utils
  76.         fi
  77.     if [ "$choice" = "8" ]; then
  78.         leave
  79.         fi
  80. done
  81. }
  82.  
  83. secmain()
  84. {
  85. while [ 0 ]; do
  86.         dialog --title " $TITLE" \
  87.         --backtitle " $TVERSION" \
  88.         --menu "User Menu" 15 50 6 \
  89.         "1" "User Menu" \
  90.         "2" "Group Menu" \
  91.         "3" "Users on `hostname`" \
  92.      "4" "Last 15 System Users" \
  93.     "5" "Login-Logout LOG" \
  94.         "6" "QUIT to Main Menu" 2> /tmp/uch.tmp.$$
  95.         if [ $? = 1 -o $? = 255 ]; then
  96.                 /bin/rm -f /tmp/tmpmsg /tmp/uch.tmp.$$
  97.                 exit
  98.         fi
  99.         uchoice=`cat /tmp/uch.tmp.$$`
  100.         /bin/rm -f /tmp/uch.tmp.$$
  101.         if [ "$uchoice" = "1" ]; then
  102.         umain
  103.     fi
  104.     if [ "$uchoice" = "2" ]; then
  105.     gmain
  106.     fi
  107.     if [ "$uchoice" = "3" ]; then
  108.     users > /tmp/users.tmp.$$
  109.         dialog --title "System Users" \
  110.         --backtitle " $TVERSION" \
  111.         --textbox /tmp/users.tmp.$$ 15 76
  112.         /bin/rm -f /tmp/users.tmp.$$
  113.         fi
  114.     if [ "$uchoice" = "4" ]; then
  115.         last -15 > /tmp/users15.tmp.$$
  116.         dialog --title "Last 15 System Users" \
  117.         --backtitle " $TVERSION" \
  118.         --textbox /tmp/users15.tmp.$$ 15 76
  119.         /bin/rm -f /tmp/users15.tmp.$$
  120.         fi
  121.     if [ "$uchoice" = "5" ]; then
  122.         /sbin/login.info > /tmp/lusers.tmp.$$
  123.         dialog --title "System Users" \
  124.         --backtitle " $TVERSION" \
  125.         --textbox /tmp/lusers.tmp.$$ 15 76
  126.         /bin/rm -f /tmp/lusers.tmp.$$
  127.         fi
  128.     if [ "$uchoice" = "6" ]; then
  129.     main
  130.     fi
  131. done
  132. }
  133. acctmain()
  134. {
  135. while [ 0 ]; do
  136.         dialog --title " $TITLE" \
  137.         --backtitle " $TVERSION" \
  138.         --menu "System Accounting " 12 50 6 \
  139.         "1" "User Quotas" \
  140.         "2" "Group Quotas" \
  141.         "3" "Edit A User Quotas" \
  142.     "4" "Edit Groups Users Quotas"\
  143.         "5" "User time on" \
  144.         "6" "QUIT to Main Menu" 2> /tmp/uch.tmp.$$
  145.         if [ $? = 1 -o $? = 255 ]; then
  146.                 /bin/rm -f /tmp/tmpmsg /tmp/uch.tmp.$$
  147.                 exit
  148.         fi
  149.         uchoice=`cat /tmp/uch.tmp.$$`
  150.         /bin/rm -f /tmp/uch.tmp.$$
  151.  
  152.         if [ "$uchoice" = "1" ]; then
  153.         /sbin/repquota -au >/tmp/repquota.tmp
  154.         dialog --title "User quotas on System" \
  155.         --backtitle " $TVERSION" \
  156.         --textbox /tmp/repquota.tmp 15 76
  157.         /bin/rm -f /tmp/repquota.tmp
  158.         fi
  159.  
  160.         if [ "$uchoice" = "2" ]; then
  161.         /sbin/repquota -avg >/tmp/gpquota.tmp
  162.         dialog --title "Group quotas on System" \
  163.         --backtitle " $TVERSION" \
  164.         --textbox /tmp/gpquota.tmp 15 76
  165.         /bin/rm -f /tmp/gpquota.tmp
  166.         fi
  167.  
  168.         if [ "$uchoice" = "3" ]; then
  169.     dialog --title "Edit quotas" \
  170.         --backtitle " $TVERSION" \
  171.         --inputbox "User to Edit:" 15 46 2> /tmp/quser.tmp
  172.     edquota -u `cat /tmp/quser.tmp`
  173.     /bin/rm -f /tmp/quser.tmp      
  174.     fi
  175.  
  176.         if [ "$uchoice" = "4" ]; then
  177.         edquota -g users
  178.         fi    
  179.  
  180.     if [ "$uchoice" = "5" ]; then
  181.     /sbin/sac -dpa >/tmp/utime.tmp
  182.         dialog --title "Users time on System" \
  183.         --backtitle " $TVERSION" \
  184.         --textbox /tmp/utime.tmp 15 76
  185.         /bin/rm -f /tmp/utime.tmp
  186.     fi
  187.  
  188.         if [ "$uchoice" = "6" ]; then
  189.         main
  190.         fi
  191. done
  192. }
  193.  
  194. nmmenu()
  195. {
  196. while [ 0 ]; do
  197.         dialog --title " News and Mail" \
  198.         --backtitle " $TVERSION" \
  199.         --msgbox "Not Implemented Yet!" 12 50 
  200.     main
  201. done
  202. }        
  203.   
  204. umain()
  205. {
  206. while [ 0 ]; do
  207.         dialog --title " $TITLE" \
  208.         --backtitle " $TVERSION" \
  209.         --menu "User Menu" 12 50 4 \
  210.         "1" "List Users" \
  211.         "2" "Add a User" \
  212.         "3" "Delete a User" \
  213.         "4" "QUIT to Security Menu" 2> /tmp/uch.tmp.$$
  214.         if [ $? = 1 -o $? = 255 ]; then
  215.                 /bin/rm -f /tmp/tmpmsg /tmp/uch.tmp.$$
  216.                 exit
  217.         fi
  218.     uchoice=`cat /tmp/uch.tmp.$$`
  219.         /bin/rm -f /tmp/uch.tmp.$$
  220.         if [ "$uchoice" = "1" ]; then
  221.     cat /etc/passwd > /tmp/tpwd.$$
  222.         dialog --title "`hostname`'s Users" \
  223.         --backtitle " $TVERSION" \
  224.     --textbox /tmp/tpwd.$$ 15 70 
  225.     /bin/rm -f /tmp/tpwd.$$
  226.         fi
  227.         if [ "$uchoice" = "2" ]; then
  228.         add-user
  229.         fi
  230.         if [ "$uchoice" = "3" ]; then
  231.         del-user
  232.         fi
  233.         if [ "$uchoice" = "4" ]; then
  234.         secmain
  235.         fi
  236. done
  237. }
  238.  
  239. gmain()
  240. {
  241. while [ 0 ]; do
  242.     dialog --title " $TITLE" \
  243.         --backtitle " $TVERSION" \
  244.         --menu "Group Menu" 12 50 4 \
  245.         "1" "List Groups" \
  246.         "2" "Add a Group" \
  247.         "3" "Delete a Group" \
  248.         "4" "QUIT to Security Menu" 2> /tmp/gch.tmp.$$
  249.         if [ $? = 1 -o $? = 255 ]; then
  250.                 /bin/rm -f /tmp/tmpmsg /tmp/gch.tmp.$$
  251.                 exit
  252.         fi
  253.         gchoice=`cat /tmp/gch.tmp.$$`
  254.         /bin/rm -f /tmp/gch.tmp.$$
  255.         if [ "$gchoice" = "1" ]; then
  256.     cat /etc/group > /tmp/tgrp.$$
  257.     dialog --title "`hostname`'s Groups" \
  258.         --backtitle " $TVERSION" \
  259.     --textbox /tmp/tgrp.$$ 15 50 
  260.     /bin/rm -f /tmp/tgrp.$$        
  261.         fi
  262.         if [ "$gchoice" = "2" ]; then
  263.         add-grp
  264.         fi
  265.     if [ "$gchoice" = "3" ]; then
  266.         del-grp
  267.         fi
  268.         if [ "$gchoice" = "4" ]; then
  269.         secmain
  270.         fi
  271. done
  272. }
  273.  
  274. smain()
  275. {
  276. while [ 0 ]; do
  277.  
  278.         dialog --title " $TITLE" \
  279.         --backtitle " $TVERSION" \
  280.         --menu "System Menu" 15 40 8 \
  281.         "1" "Memory Status" \
  282.         "2" "File Systems Status" \
  283.     "3" "System Load" \
  284.         "4" "System Proc Info" \
  285.     "5" "User Status"\
  286.     "6" "FileSystem Maintainance" \
  287.     "7" "Backup & Restore" \
  288.         "8" "QUIT to Main Menu" 2> /tmp/sch.tmp.$$
  289.         if [ $? = 1 -o $? = 255 ]; then
  290.                 /bin/rm -f /tmp/tmpmsg /tmp/sch.tmp.$$
  291.                 exit
  292.         fi
  293.         schoice=`cat /tmp/sch.tmp.$$`
  294.         /bin/rm -f /tmp/sch.tmp.$$
  295.  
  296.         if [ "$schoice" = "1" ]; then
  297.         free > /tmp/free.tmp.$$
  298.     dialog --title " Memory Stats" \
  299.         --backtitle " $TVERSION" \
  300.         --textbox /tmp/free.tmp.$$ 12 70 
  301.     /bin/rm -f /tmp/free.tmp.$$
  302.         fi
  303.  
  304.         if [ "$schoice" = "2" ]; then
  305.     dfck > /tmp/df.$$
  306.         dialog --title " Filesystem Stats" \
  307.         --backtitle " $TVERSION" \
  308.         --textbox /tmp/df.$$ 15 76
  309.     /bin/rm -f /tmp/df.$$
  310.         fi
  311.     if [ "$schoice" = "3" ]; then
  312.         /sbin/load > /tmp/sysload.$$
  313.         dialog --title " System Load" \
  314.         --backtitle " $TVERSION" \
  315.         --textbox /tmp/sysload.$$ 15 46
  316.         /bin/rm -f /tmp/sysload.$$
  317.         fi
  318.  
  319.     if [ "$schoice" = "4" ]; then
  320.         procinfo > /tmp/sproc.tmp.$$
  321.         dialog --title "System Processes Information" \
  322.         --backtitle " $TVERSION" \
  323.         --textbox /tmp/sproc.tmp.$$ 18 76
  324.         /bin/rm -f /tmp/sproc.tmp.$$
  325.         fi
  326.  
  327.         if [ "$schoice" = "5" ]; then
  328.         users > /tmp/users.tmp.$$
  329.         dialog --title "System Users" \
  330.         --backtitle " $TVERSION" \
  331.         --textbox /tmp/users.tmp.$$ 15 76
  332.         /bin/rm -f /tmp/users.tmp.$$
  333.         fi
  334.  
  335.     if [ "$schoice" = "6" ]; then
  336.     fsmaint
  337.         fi
  338.  
  339.     if [ "$schoice" = "7" ]; then
  340.     /sbin/lbu
  341.     fi
  342.  
  343.         if [ "$schoice" = "8" ]; then
  344.         main
  345.         fi
  346. done
  347. }
  348.  
  349. nmenu()
  350. {
  351. while [ 0 ]; do
  352.  
  353.         dialog --title " $TITLE" \
  354.         --backtitle " $TVERSION" \
  355.         --menu "Network Menu" 14 40 7 \
  356.         "1" "Network Status" \
  357.     "2" "Network Accounts Activity" \
  358.         "3" "Check IP Address Table" \
  359.     "4" "Check ARP Tables" \
  360.         "5" "Ping a system" \
  361.     "6" "Check Kernel Routing Table" \
  362.         "7" "QUIT to Main Menu" 2> /tmp/nch.tmp.$$
  363.         if [ $? = 1 -o $? = 255 ]; then
  364.                 /bin/rm -f /tmp/tmpmsg /tmp/nch.tmp.$$
  365.                 exit
  366.         fi
  367.     nchoice=`cat /tmp/nch.tmp.$$`
  368.         /bin/rm -f /tmp/nch.tmp.$$
  369.         if [ "$nchoice" = "1" ]; then
  370.         netstat > /tmp/nstat.tmp.$$
  371.         dialog --title " Network Stats" \
  372.         --backtitle " $TVERSION" \
  373.         --textbox /tmp/nstat.tmp.$$ 12 70
  374.         /bin/rm -f /tmp/nstat.tmp.$$
  375.         fi
  376.  
  377.         if [ "$nchoice" = "2" ]; then
  378.         /sbin/sl2rdbl /var/adm/net-acct > /tmp/netacct.$$
  379.         dialog --title " Network Activity on $HOSTNAME" \
  380.         --backtitle "$TVERSION" \
  381.         --textbox /tmp/netacct.$$ 15 76
  382.     /bin/rm -f /tmp/netacct.$$
  383.         fi
  384.  
  385.         if [ "$nchoice" = "3" ]; then
  386.         ifconfig > /tmp/ifc.$$
  387.         dialog --title " Check IP Address" \
  388.         --backtitle "$TVERSION" \
  389.         --textbox /tmp/ifc.$$ 15 76
  390.         /bin/rm -f /tmp/ifc.$$
  391.         fi
  392.         if [ "$nchoice" = "4" ]; then
  393.         arp -a > /tmp/arp.tmp.$$
  394.         dialog --title "Look at ARP Table for $HOSTNAME" \
  395.         --backtitle "$TVERSION" \
  396.         --textbox /tmp/arp.tmp.$$ 15 70
  397.         /bin/rm -f /tmp/arp.tmp.$$
  398.         fi
  399.         if [ "$nchoice" = "5" ]; then
  400.     dialog --title "Get address to Ping" \
  401.     --backtitle "$TVERSION" \
  402.     --inputbox "What IP address to PING?" 10 70 2> /tmp/tmp.msg.$$
  403.     Paddr=`cat /tmp/tmp.msg.$$`
  404.     /bin/rm -f /tmp/tmp.msg.$$
  405.         ping -c 10 $Paddr > /tmp/ping.tmp.$$
  406.         dialog --title "Pinging $Paddr" \
  407.         --backtitle "$TVERSION" \
  408.         --textbox /tmp/ping.tmp.$$ 18 76
  409.         /bin/rm -f /tmp/ping.tmp.$$
  410.         fi
  411.         if [ "$nchoice" = "6" ]; then
  412.         /sbin/route -n > /tmp/krt.$$
  413.         dialog --title " Kernel Routing Table" \
  414.         --backtitle "$TVERSION" \
  415.         --textbox /tmp/krt.$$ 15 78
  416.         /bin/rm -f /tmp/krt.$$
  417.         fi    
  418.         if [ "$nchoice" = "7" ]; then
  419.         main
  420.         fi
  421. done
  422. }
  423.  
  424. utils()
  425. {
  426. while [ 0 ]; do
  427.  
  428.         dialog --title " $TITLE" \
  429.         --backtitle " $TVERSION" \
  430.         --menu "Utilities Menu" 14 50 6 \
  431.         "1" "Check & Edit System Processes" \
  432.         "2" "File Manager" \
  433.         "3" "System News Editor" \
  434.         "4" "Edit CRONTABS" \
  435.     "5" "TeX MGR - Process .tex, .dvi & .ps files" \
  436.         "6" "QUIT to Main Menu" 2> /tmp/util.tmp.$$
  437.         if [ $? = 1 -o $? = 255 ]; then
  438.                 /bin/rm -f /tmp/tmpmsg /tmp/util.tmp.$$
  439.                 exit
  440.         fi
  441.         utilch=`cat /tmp/util.tmp.$$`
  442.         /bin/rm -f /tmp/util.tmp.$$
  443.         if [ "$utilch" = "1" ]; then
  444.         gitps
  445.         fi
  446.         if [ "$utilch" = "2" ]; then
  447.         git
  448.         fi
  449.         if [ "$utilch" = "3" ]; then
  450.         news-edt
  451.         fi
  452.         if [ "$utilch" = "4" ]; then
  453.         cron-edt
  454.         fi
  455.     if [ "$utilch" = "5" ]; then
  456.         texmgr
  457.         fi
  458.         if [ "$utilch" = "6" ]; then
  459.         main
  460.         fi
  461.  
  462. done
  463. }
  464.  
  465. leave()
  466. {
  467. while [ 0 ]; do
  468.  
  469.         dialog --title " $TITLE" \
  470.     --backtitle " $TVERSION" \
  471.         --menu "Prepare Admin.Log" 12 45 3 \
  472.         "1" "View Admin.Log" \
  473.         "2" "Update Admin.Log" \
  474.         "3" "QUIT" 2> /tmp/mych.tmp.$$
  475.         if [ $? = 1 -o $? = 255 ]; then
  476.                 /bin/rm -f /tmp/tmpmsg /tmp/mych.tmp.$$
  477.                 exit
  478.         fi
  479.         lchoice=`cat /tmp/mych.tmp.$$`
  480.         /bin/rm -f /tmp/mych.tmp.$$
  481.  
  482.      if [ "$lchoice" = "1" ]; then
  483.         dialog --title " $TITLE"\
  484.     --backtitle " $TVERSION" \
  485.         --textbox /var/adm/Admin.Log 18 70
  486.         /bin/rm -f /tdoneron.tmp.$$
  487.         fi
  488.  
  489.     if [ "$lchoice" = "2" ]; then
  490.     $AEDIT /var/adm/Admin.Log
  491.     fi
  492.  
  493.         if [ "$lchoice" = "3" ]; then
  494.     clear
  495.         exit
  496.         fi
  497. done
  498. }
  499.  
  500. add-user()
  501. {
  502. while [ 0 ]; do
  503.     dialog --title "Add A New User" \
  504.     --backtitle " $TVERSION" \
  505.     --inputbox "New Users LOGIN Name (at least 6 Chars):" 10 70 2> /tmp/user.tmp.$$
  506.     UserName=`cat /tmp/user.tmp.$$`
  507.     /bin/rm -f /tmp/user.tmp.$$
  508.  
  509.         dialog --title "Add A New User" \
  510.     --backtitle " $TVERSION" \
  511.         --inputbox "$UserName's Full Name:" 10 70 2> /tmp/fuser.tmp.$$
  512.         FNAME=`cat /tmp/fuser.tmp.$$`
  513.         /bin/rm -f /tmp/fuser.tmp.$$
  514.     LUID=`tail -1 /etc/passwd | cut -f3 -d:` 
  515.     NUID=`expr $LUID + 1`
  516.         dialog --title "Add A New User" \
  517.     --backtitle " $TVERSION" \
  518.         --msgbox "$UserName's ID (number) is:$NUID" 10 70    
  519.      
  520.         dialog --title "Add A New User" \
  521.     --backtitle " $TVERSION" \
  522.         --inputbox "$UserName's Group ( hit ENTER for default group \
  523. of USERS (100)):" 10 75 2> /tmp/guser.tmp.$$
  524.     if [ "`cat /tmp/guser.tmp.$$`" = "" ]; then
  525.       NGID="100"
  526.     else
  527.           NGID=`cat /tmp/guser.tmp.$$`
  528.     fi
  529.         /bin/rm -f /tmp/guser.tmp.$$
  530.  
  531.         dialog --title "Add A New User" \
  532.     --backtitle " $TVERSION" \
  533.         --inputbox "$UserName's Home Directory: \
  534. Hit ENTER for default:/home/users/$UserName " 10 75 2> /tmp/duser.tmp.$$
  535.     if [ "`cat /tmp/duser.tmp.$$`" = "" ]; then
  536.           HDIR=/home/users/$UserName 
  537.         else
  538.           HDIR=`cat /tmp/duser.tmp.$$`
  539.     fi
  540.         /bin/rm -f /tmp/duser.tmp.$$
  541.  
  542.         dialog --title "Add A New User" \
  543.     --backtitle " $TVERSION" \
  544.         --inputbox "$UserName's Shell \
  545. (Hit ENTER for default:/bin/bash)" 10 70 2> /tmp/suser.tmp.$$
  546.         if [ "`cat /tmp/suser.tmp.$$`" = "" ]; then
  547.           NSHELL=/bin/bash
  548.         else
  549.         NSHELL=`cat /tmp/suser.tmp.$$`
  550.     fi
  551.         /bin/rm -f /tmp/suser.tmp.$$
  552.  
  553.  
  554.     dialog --title "Add A New User" \
  555.     --backtitle " $TVERSION" \
  556.         --yesno "    New User: $UserName \n
  557.     Full Name: $FNAME \n
  558.     UID: $NUID \n
  559.     GID: $NGID \n
  560.     Home Dir: $HDIR \n
  561.     Shell: $NSHELL " 16 50
  562.     case $? in
  563.           0)
  564.           echo $UserName"::"$NUID":"$NGID":"$FNAME":"$HDIR":"$NSHELL >>$EPWORD
  565.           echo "`date` - $UID added user:$UserName" >>/var/adm/Admin.Log
  566.               echo $UserName"::"$NUID":"$NGID":"$FNAME":"$HDIR":"$NSHELL >>/var/adm/Admin.Log
  567.           mkdir $HDIR
  568.           cp  /etc/skel/.* $HDIR
  569.               chown -R $UserName.$NGID $HDIR 
  570.           touch $UMAIL/$UserName
  571.           chown -R $UserName.mail $UMAIL/$UserName
  572.           umain ;;
  573.                1)
  574.             umain ;;
  575.           255)
  576.                 echo "ESC pressed."  
  577.             umain ;;
  578.     esac
  579. done
  580. }
  581.  
  582. del-user()
  583. {
  584. while [ 0 ]; do
  585.     dialog --title "Delete User(s)" \
  586.     --backtitle "$TVERISON" \
  587.     --inputbox "What user to be removed?" 10 50 2> /tmp/duser.tmp.$$
  588.     DUSER=`cat /tmp/duser.tmp.$$`
  589.         if [ $DUSER = " " ]; then
  590.            gmain
  591.         fi
  592.         /bin/rm /tmp/duser.tmp.$$
  593.         pwget -x -n $DUSER > /tmp/DU.tmp.$$
  594.         HDIR=`pwget -n $DUSER -f '%d'`
  595.         /bin/cp /tmp/DU.tmp.$$ $EPWORD
  596.         
  597.         sed s/,$DUSER\$// <$EGROUP | sed s/\\:$DUSER\$/\\:/ | sed s/,$DUSER,/,/ | \
  598.         sed s/\\:$DUSER,/\\:/ > /tmp/DU.tmp.$$
  599.         /bin/cp /tmp/DU.tmp.$$ $EGROUP
  600.         /bin/rm -rf $HDIR
  601.         /bin/rm -f $UMAIL/$DUSER
  602.         /bin/rm -f /tmp/DU.tmp.$$
  603.         echo "`date` - $UID deleted User:$DUSER" >> /var/adm/Admin.Log
  604.         checkusers >> /var/adm/Admin.Log
  605.         umain    
  606. done
  607. }
  608.  
  609. add-grp()
  610. {
  611. while [ 0 ]; do
  612.     dialog --title "Add A Group" \
  613.     --backtitle "$TVERISON" \
  614.     --inputbox "Groupname to add:" 8 50 2> /tmp/ngrp.tmp.$$
  615.     NGRP=`cat /tmp/ngrp.tmp.$$`
  616.     /bin/rm /tmp/ngrp.tmp.$$
  617.     dialog --title "Add A Group" \
  618.         --backtitle " $TVERSION" \
  619.     --inputbox "GroupID:" 8 50 2> /tmp/ngid.tmp.$$
  620.     NGID=`cat /tmp/ngid.tmp.$$`
  621.     /bin/rm /tmp/ngid.tmp.$$
  622.     dialog --title "Add A Group" --clear \
  623.         --backtitle " $TVERSION" \
  624.     --yesno "Assign $NGRP a password? (y/N)" 8 50
  625.  
  626.     case $? in
  627.         0)
  628.             clear
  629.             getpass 1>/tmp/npw.tmp.$$
  630.             PWORD=`cat /tmp/npw.tmp.$$`
  631.             /bin/rm -f /tmp/npw.tmp.$$;;
  632.         1)
  633.             PWORD='';;
  634.  
  635.     esac
  636.  
  637.     dialog --title "Add A Group" \
  638.         --backtitle " $TVERSION" \
  639.     --msgbox "Now Adding new group $NGRP" 8 50 
  640.     echo $NGRP":"$PWORD":"$NGID":" >> $EGROUP
  641.     echo "`date` - $UID added group:$NGRP:$P1WORD:$NGID: " >>/var/adm/Admin.Log
  642.  
  643. gmain    
  644. done
  645. }
  646.  
  647. del-grp()
  648. {
  649. while [ 0 ]; do
  650.     dialog --title "Delete a Group" \
  651.         --backtitle " $TVERSION" \
  652.     --inputbox "Which group to delete?" 8 50 2> /tmp/dgrp.tmp.$$
  653.     DGRP=`cat /tmp/dgrp.tmp.$$`
  654.     /bin/rm -f /tmp/dgrp.tmp.$$
  655.     dialog --title "Delete a Group" \
  656.         --backtitle " $TVERSION" \
  657.     --msgbox "Deleting group $DGRP" 8 50
  658.     echo "`date` - $UID deleted group: $DGRP" >>/var/adm/Admin.Log
  659.     grget -n $DGRP -x >/tmp/DG.tmp.$$
  660.     /bin/cp /tmp/DG.tmp.$$ $EGROUP
  661.     /bin/rm -f /tmp/DG.tmp.$$
  662.     gmain
  663. done
  664. }        
  665.  
  666. cron-edt()
  667. {
  668. while [ 0 ]; do
  669.  
  670.         dialog --title " $TITLE" \
  671.         --backtitle " $TVERSION" \
  672.         --menu "Edit CRONTAB Files" 12 50 3 \
  673.         "1" "List crontab files" \
  674.         "2" "Edit a file" \
  675.         "3" "QUIT to Main Menu" 2> /tmp/cech.tmp.$$
  676.         if [ $? = 1 -o $? = 255 ]; then
  677.                 /bin/rm -f /tmp/tmpmsg /tmp/cech.tmp.$$
  678.                 main
  679.         fi
  680.         cechoice=`cat /tmp/cech.tmp.$$`
  681.         /bin/rm -f /tmp/cech.tmp.$$
  682.  
  683.         if [ "$cechoice" = "1" ]; then
  684.         /bin/ls /var/spool/cron/crontabs > /tmp/cront.tmp.$$
  685.         dialog --title "`hostname`'s CRONTAB Files" \
  686.         --backtitle " $TVERSION" \
  687.         --textbox /tmp/cront.tmp.$$ 15 70
  688.         /bin/rm -f /tmp/cront.tmp.$$
  689.         fi
  690.  
  691.         if [ "$cechoice" = "2" ]; then
  692.         cd /var/spool/cron/crontabs
  693.      dialog --title "SCANNING" \
  694.         --backtitle " $TVERSION" \
  695.     --infobox "Please wait while I look for files." 7 40
  696.     echo 'dialog --backtitle " $TVERSION" --menu "Please select the file to edit." 15 45 8 \'> /tmp/viewscr$$
  697.         if [ "`ls /var/sysnews/* 2>/dev/null`" = "" ]; then
  698.                 dialog --title "NO FILE FOUND" \
  699.                 --msgbox "No files found." 10 30
  700.         else
  701.                 /bin/ls *|sed -e '/*/s///'|sed -e 's/.*/"&" "" \\/' >> /tmp/viewscr$$
  702.                 echo "2> /tmp/return\$\$" >> /tmp/viewscr$$
  703.                 while [ 0 ]; do
  704.                         source /tmp/viewscr$$
  705.                         if [ ! "`cat /tmp/return$$`" = "" ]; then
  706.                                 EDTFILE=`cat /tmp/return$$`
  707.                                 break
  708.                         else
  709.                 EDTFILE=`cat /tmp/return$$`
  710.                         fi
  711.                 done
  712.                 /bin/rm -f /tmp/return$$ /tmp/viewscr$$ /tmp/tmpmsg
  713.         fi
  714.         $AEDIT /var/spool/cron/crontabs/$EDTFILE
  715.         cd /
  716.         fi
  717.         if [ "$cechoice" = "3" ]; then
  718.         utils
  719.         fi
  720. done
  721. }
  722.  
  723. news-edt()
  724. {
  725. while [ 0 ]; do
  726.  
  727.         dialog --title " $TITLE" \
  728.         --backtitle " $TVERSION" \
  729.         --menu "Edit the System News Files" 12 50 4 \
  730.         "1" "List news files" \
  731.         "2" "Edit a file" \
  732.         "3" "Run News" \
  733.         "4" "QUIT to Main Menu" 2> /tmp/nech.tmp.$$
  734.         if [ $? = 1 -o $? = 255 ]; then
  735.                 /bin/rm -f /tmp/tmpmsg /tmp/nech.tmp.$$
  736.                 exit
  737.         fi
  738.         nechoice=`cat /tmp/nech.tmp.$$`
  739.         /bin/rm -f /tmp/nech.tmp.$$
  740.  
  741.         if [ "$nechoice" = "1" ]; then
  742.         /bin/ls /var/sysnews > /tmp/news.tmp.$$
  743.         dialog --title "`hostname`'s News Files" \
  744.         --backtitle " $TVERSION" \
  745.         --textbox /tmp/news.tmp.$$ 15 70
  746.         /bin/rm -f /tmp/news.tmp.$$
  747.         fi
  748.  
  749.         if [ "$nechoice" = "2" ]; then
  750.     cd /var/sysnews
  751.     dialog --backtitle " $TVERSION" --title "SCANNING" --infobox "Please wait while I look for files." 7 40    
  752.     echo 'dialog --menu "Please select the file to edit." 15 45 8 \'> /tmp/viewscr$$
  753.     if [ "`ls /var/sysnews/* 2>/dev/null`" = "" ]; then
  754.             dialog --title "NO FILE FOUND" \
  755.             --msgbox "No files found." 10 30
  756.        else
  757.             ls *|sed -e '/*/s///'|sed -e 's/.*/"&" "" \\/' >> /tmp/viewscr$$
  758.             echo "2> /tmp/return\$\$" >> /tmp/viewscr$$
  759.             while [ 0 ]; do
  760.                     source /tmp/viewscr$$
  761.                     if [ ! "`cat /tmp/return$$`" = "" ]; then
  762.                             EDTFILE=`cat /tmp/return$$`
  763.                             break
  764.                     else
  765.             EDTFILE=`cat /tmp/return$$`
  766.                     fi
  767.             done
  768.             /bin/rm -f /tmp/return$$ /tmp/viewscr$$ /tmp/tmpmsg
  769.     fi
  770.     $AEDIT /var/sysnews/$EDTFILE
  771.     cd /
  772.         fi
  773.         if [ "$nechoice" = "3" ]; then
  774.         news
  775.         fi
  776.         if [ "$nechoice" = "4" ]; then
  777.         utils
  778.         fi
  779. done
  780. }
  781.  
  782. prnt-mgmt()
  783. {
  784. while [ 0 ]; do
  785.  
  786.         dialog --title " $TITLE" \
  787.         --backtitle " $TVERSION" \
  788.         --menu "Print Queue Management" 18 60 11 \
  789.         "status" "Check Print Queue status" \
  790.         "kill" "Kill a Print Job" \
  791.         "clean" "Clean All Print Queues" \
  792.     "stop" "Turn off Printing" \
  793.     "start" "Turn on Printing"\
  794.     "down" "Down a Queue and notify Users" \
  795.     "up" "Up a previously downed Queue" \
  796.     "topq" "Reorder Jobs in a Queue" \
  797.     "stopall" "Stop ALL QUEUES" \
  798.     "startall" "Start ALL QUEUES" \
  799.     "exit" "Exit to Main Menu" 2> /tmp/pmch.tmp.$$
  800.         if [ $? = 1 -o $? = 255 ]; then
  801.                 /bin/rm -f /tmp/tmpmsg /tmp/pmch.tmp.$$
  802.                 exit
  803.         fi
  804.         pmchoice=`cat /tmp/pmch.tmp.$$`
  805.         /bin/rm -f /tmp/pmch.tmp.$$
  806.         if [ "$pmchoice" = "status" ]; then
  807.         lpc status > /tmp/qstat.tmp.$$
  808.         dialog --title "Queue Status" \
  809.         --backtitle " $TVERSION" \
  810.         --textbox /tmp/qstat.tmp.$$ 15 70
  811.         /bin/rm -f /tmp/qstat.tmp.$$
  812.         fi
  813.         if [ "$pmchoice" = "kill" ]; then 
  814.     que_list
  815.     proc_list
  816.     lprm $WFILE -P$PQUE
  817.         fi
  818.         if [ "$pmchoice" = "clean" ]; then
  819.         lpc clean all
  820.         fi
  821.     if [ "$pmchoice" = "stop" ]; then
  822.     que_list
  823.     lpc stop $PQUE
  824.     dialog --title "Queue Status" \
  825.         --backtitle " $TVERSION" \
  826.     --msgbox "$PQUE stopped" 8 50
  827.     fi
  828.     if [ "$pmchoice" = "start" ]; then
  829.     que_list
  830.     lpc start $PQUE
  831.      fi
  832.     if [ "$pmchoice" = "down" ]; then
  833.         que_list
  834.         lpc down $PQUE
  835.         fi
  836.     if [ "$pmchoice" = "up" ]; then
  837.         que_list
  838.         lpc up $PQUE
  839.         fi
  840.         if [ "$pmchoice" = "topq" ]; then
  841.         que_list
  842.     proc_list
  843.         lpc topq $PQUE $WFILE
  844.         fi
  845.     if [ "$pmchoice" = "stopall" ]; then
  846.         lpc down all > /tmp/stall.$$ 
  847.     /bin/rm -f /tmp/stall.$$
  848.         fi
  849.     if [ "$pmchoice" = "startall" ]; then
  850.         lpc up all > /tmp/stall.$$ 
  851.     /bin/rm -f /tmp/stall.$$
  852.         fi
  853.     if [ "$pmchoice" = "exit" ]; then
  854.         main
  855.         fi
  856. done
  857. }
  858.  
  859. que_list()
  860. {
  861.  
  862.    dialog --backtitle " $TVERSION" --title "SCANNING" --infobox "Please wait while I look for files." 7 45
  863.    echo 'dialog --menu "Please select the file to edit." 15 78 12 \'> /tmp/que.$$
  864.    if [ "`cat /etc/pqueues 2>/dev/null`" = "" ]; then
  865.        dialog --title "NO FILE FOUND" \
  866.        --msgbox "No Queues Found!" 10 30
  867.     exit
  868.    else
  869.  
  870.         cat /etc/pqueues |sed -e '/*/s///'|sed -e 's/.*/"&" "" \\/' >> /tmp/que.$$
  871.         echo "2> /tmp/qreturn\$\$" >> /tmp/que.$$
  872.         while [ 0 ]; do
  873.                 source /tmp/que.$$
  874.                 if [ ! "`cat /tmp/qreturn$$`" = "" ]; then
  875.                         PQUE=`cat /tmp/qreturn$$`
  876.                         break
  877.                 else
  878.                         break
  879.                 fi
  880.         done
  881.    fi
  882. /bin/rm -f /tmp/qreturn$$ /tmp/que.$$
  883. }
  884.  
  885. proc_list()
  886. {
  887.    CMD="lpq -P$PQUE"
  888.    dialog --backtitle " $TVERSION" --title "Looking in $PQUE" --infobox "Please wait while I look." 7 45
  889.    echo 'dialog --menu "Please select the job." 15 78 12 \'> /tmp/viewscr$$
  890.    if [ "`$CMD 2>/dev/null`" = "" ]; then
  891.    dialog --title "NO QUEUE FOUND" \
  892.         --msgbox "No queues found." 10 30
  893.    else
  894.         $CMD|sed -e '/*/s///'|sed -e 's/.*/"&" "" \\/' >> /tmp/viewscr$$
  895.         echo "2> /tmp/return\$\$" >> /tmp/viewscr$$
  896.         while [ 0 ]; do
  897.                 source /tmp/viewscr$$
  898.                 if [ ! "`cat /tmp/return$$`" = "" ]; then
  899.             cut -c19-23 /tmp/return$$ > /tmp/edit.$$
  900.                         WFILE=`cat /tmp/edit.$$`
  901.             dialog --title "Job to Delete" \
  902.             --textbox /tmp/edit.$$  8 50
  903.                         break
  904.                 else
  905.                         break
  906.                 fi
  907.     done
  908.    fi
  909. /bin/rm -f /tmp/return$$ /tmp/viewscr$$ /tmp/tmpmsg /tmp/edit.$$
  910. }
  911.  
  912. fsmaint()
  913. {
  914. while [ 0 ]; do
  915.  
  916.         dialog --title " $TITLE" \
  917.         --backtitle " $TVERSION" \
  918.         --menu "Filesystem Maintainance" 14 60 6 \
  919.         "H" "FS Hints & Tips - Help Text" \
  920.     "1" "Check USER Directories" \
  921.         "2" "Find Duplicate files (/bin /usr/bin)" \
  922.     "3" "Send duplicate files list to printer" \
  923.         "4" "Compress Log Files (syslog, wtmp, utmp & messages)" \
  924.         "5" "QUIT to Main Menu" 2> /tmp/mych.tmp.$$
  925.         if [ $? = 1 -o $? = 255 ]; then
  926.                 /bin/rm -f /tmp/tmpmsg /tmp/mych.tmp.$$
  927.                 exit
  928.         fi
  929.         nchoice=`cat /tmp/mych.tmp.$$`
  930.         /bin/rm -f /tmp/mych.tmp.$$
  931.         if [ "$nchoice" = "H" ]; then
  932.         dialog --title "`hostname`'s Filesystem" \
  933.         --backtitle " $TVERSION" \
  934.         --textbox /usr/doc/fs.text 15 70
  935.         fi
  936.     if [ "$nchoice" = "1" ]; then
  937.         dialog --title "User Space Check" \
  938.     --backtitle " $TVERSION" \
  939.     --infobox "Please wait... " 5 50
  940.     /sbin/usrdsksp 
  941.     dialog --title "`hostname`'s Users" \
  942.         --backtitle " $TVERSION" \
  943.         --textbox /tmp/user.chk 15 70
  944.     /bin/rm -f /tmp/user.chk 
  945.     fi
  946.         if [ "$nchoice" = "2" ]; then
  947.     dialog --backtitle " $TVERSION" --title "SCANNING" --infobox "Please wait... looking for duplicate files." 7 60    
  948.     /usr/bin/diff -s /bin /usr/bin >/tmp/diff.tmp
  949.     /bin/touch /tmp/diff.files
  950.     /usr/bin/grep "Files" /tmp/diff.tmp >>/tmp/diff.files
  951.     /bin/rm /tmp/diff.tmp
  952.     dialog --title " $TITLE" \
  953.         --backtitle " $TVERSION" \
  954.     --textbox /tmp/diff.files 20 75
  955.         fi
  956.         if [ "$nchoice" = "3" ]; then
  957.         /usr/bin/lpr /tmp/diff.files
  958.     /bin/rm /tmp/diff.files
  959.         fi
  960.         if [ "$nchoice" = "4" ]; then
  961.         dialog --title "Log Maintainance" \
  962.         --backtitle " $TVERSION" \
  963.     --infobox "Compressing files and building new files.. Please Wait." 5 60
  964.     /bin/compress -f /var/adm/wtmp /var/adm/utmp /var/adm/messages /var/adm/syslog
  965.     /bin/touch /var/adm/messages /var/adm/wtmp /var/adm/utmp /var/adm/syslog
  966.         fi
  967.     if [ "$nchoice" = "5" ]; then
  968.         smain
  969.         fi
  970. done
  971. }
  972.  
  973. logins()
  974. {
  975. SRC_FILE=/usr/adm/logins
  976.  
  977. IFS="."
  978. sort +1 +0 +3 -t"." $SRC_FILE | while read DIRECTION USER TTY DATE
  979. do
  980.    echo "$DIRECTION $USER $TTY $DATE"
  981. done
  982. }
  983.  
  984. if [ $log_name != "root" ]; then
  985.    dialog --backtitle " $TVERSION" \
  986.    --msgbox "You got to be the SUPERUSER to run!" 5 50
  987.    else
  988.    cp /etc/passwd $PWBACK
  989.    cp /etc/group $GRPBACK
  990.    main
  991. fi
  992.  
  993. if [ $log_group != "adm" ]; then
  994.    dialog --backtitle "$TVERSION" \
  995.    --msgbox "You got be Administrative to run!" 5 50
  996.    else
  997.    cp /etc/passwd $PWBACK
  998.    cp /etc/group $PWBACK
  999.    main
  1000. fi
  1001.  
  1002.